/*
界面管理类，用于进行页面的跳转
 */

package sample;

import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;


import java.io.IOException;

public class SceneManager {
    static AnchorPane root= null;
    public static void SwitchToSchedulePage(ActionEvent event) //转到课表主界面
    {
        try {
            root = FXMLLoader.load(SceneManager.class.getResource("SchedulePage.fxml"));
            Stage stage=(Stage) ((Node)event.getSource()).getScene().getWindow();
            Scene scene=new Scene(root);
            stage.setScene(scene);
            stage.show();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void SwitchToSearchTeacherTtblePage(ActionEvent event) //转到查找老师课表的界面
    {
        try {
            root = FXMLLoader.load(SceneManager.class.getResource("SearchTeacherTtblePage.fxml"));
            Stage stage=(Stage) ((Node)event.getSource()).getScene().getWindow();
            Scene scene=new Scene(root);
            stage.setScene(scene);
            stage.show();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    public static void SwitchToSearchRoomTtblePage(ActionEvent event) //转到查找教室课表界面
    {
        try {
            root = FXMLLoader.load(SceneManager.class.getResource("SearchRoomTtblePage.fxml"));
            Stage stage=(Stage) ((Node)event.getSource()).getScene().getWindow();
            Scene scene=new Scene(root);
            stage.setScene(scene);
            stage.show();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    public static void SwitchToNotePage(ActionEvent event) //转到笔记主界面
    {
        try {
            root = FXMLLoader.load(SceneManager.class.getResource("ClassNote.fxml"));
            Stage stage=(Stage) ((Node)event.getSource()).getScene().getWindow();
            Scene scene=new Scene(root);
            stage.setScene(scene);
            stage.show();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    public static void SwitchToAddNotePage(ActionEvent event) //转到添加笔记的界面
    {
        try {
            root = FXMLLoader.load(SceneManager.class.getResource("AddNote.fxml"));
            Stage stage=(Stage) ((Node)event.getSource()).getScene().getWindow();
            Scene scene=new Scene(root);
            stage.setScene(scene);
            stage.show();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    public static void SwitchToDeleteNotePage(ActionEvent event) //转到删除笔记的界面
    {
        try {
            root = FXMLLoader.load(SceneManager.class.getResource("deleteNote.fxml"));
            Stage stage=(Stage) ((Node)event.getSource()).getScene().getWindow();
            Scene scene=new Scene(root);
            stage.setScene(scene);
            stage.show();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
